﻿using CatUtils.Utils.Currency;
using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.Currency.TextUtils;
using CatUtils.Utils.SpecialUtils.PicBed.Sina;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace RabbitDownload.WebSite.Pixiv.PixivDay
{
    public partial class EveryDayBatchControl : UserControl
    {
        public EveryDayBatchControl()
        {
            InitializeComponent();
            //   dateTimePicker1.Value=DateTime.Now.Add()
            comboBox1.SelectedIndex = 0;
            dateTimePicker1.Value = dateTimePicker1.Value.AddDays(-5);
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            Helper.ViewHelper.TextBoxHelper.PrintCount(e);

            PixivStaticValue.ExcludeOpenFlag = checkBox3.Checked;
            PixivStaticValue.BlockComic = checkBox1.Checked;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            StartCycle();
        }

        private void StartCycle()
        {
            for (int i = 0; i < TextHelper.StringToInt(textBox1.Text); i++)
            {
                PixivDayScanner.Start(dateTimePicker1.Value.AddDays(i).ToString("yyyyMMdd"), PixivDayScanner.GetAPI(comboBox1.Text), TextHelper.StringToInt(textBox2.Text), comboBox1.Text);
            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            PixivStaticValue.BlockComic = checkBox1.Checked;
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            Helper.ViewHelper.TextBoxHelper.PrintCount(e);
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            PixivStaticValue.ExcludeOpenFlag = checkBox3.Checked;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            List<string> ApiList = new List<string>();

            for (int i = 0; i < TextHelper.StringToInt(textBox1.Text); i++)
            {
                ApiList.AddRange(new PixivDayEnhanceTool().InitApi(dateTimePicker1.Value.AddDays(i).ToString("yyyyMMdd"),
                 PixivDayScanner.GetAPI(comboBox1.Text)));
                Console.WriteLine("API已加入{0}个", ApiList.Count);
            }
            new PixivDayEnhanceTool().ScannerArtID(ApiList);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            new PixivDayEnhanceTool().ClearArticleId(FileHelper.SelectFile(), textboxOnlyCount1.Text);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            new PixivLoginForm("https://pixiv.net").Show();
        }
    }
}